{% extends "base.html" %}

{% block content %}
<div class="dashboard-container">
    <div class="row">
        <div class="col-md-12 mb-4">
            <div class="card">
                <div class="card-body">
                    <h2 class="card-title">欢迎，{{ user.first_name|default:user.username }}！</h2>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4 mb-4">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title h5 mb-0">
                        <i class="bi bi-lightning"></i> 快速操作
                    </h3>
                </div>
                <div class="card-body">
                    <div class="list-group">
                        <a href="{% url 'profile' %}" class="list-group-item list-group-item-action">
                            <i class="bi bi-person"></i> 编辑个人资料
                        </a>
                        <a href="{% url 'password_change' %}" class="list-group-item list-group-item-action">
                            <i class="bi bi-key"></i> 修改密码
                        </a>
                        {% if user.is_staff %}
                        <a href="{% url 'admin:index' %}" class="list-group-item list-group-item-action">
                            <i class="bi bi-gear"></i> 管理后台
                        </a>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-8 mb-4">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title h5 mb-0">
                        <i class="bi bi-bell"></i> 最近的报警记录
                    </h3>
                </div>
                <div class="card-body">
                    {% if alarms %}
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>时间</th>
                                        <th>消息</th>
                                    </tr>
                                </thead>
                                <tbody>
                                {% for alarm in alarms %}
                                    <tr>
                                        <td>{{ alarm.triggered_at }}</td>
                                        <td>{{ alarm.message }}</td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    {% else %}
                        <p class="text-muted mb-0">暂无报警记录</p>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 